package com.ruoyi.process.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.process.domain.Processflow;
import com.ruoyi.process.service.IProcessflowService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * indexController
 * 
 * @author wuenguo
 * @date 2025-06-10
 */
@RestController
@RequestMapping("/camunda/processflow")
public class ProcessflowController extends BaseController
{
    @Autowired
    private IProcessflowService processflowService;

    /**
     * 查询index列表
     */
    @PreAuthorize("@ss.hasPermi('camunda:processflow:list')")
    @GetMapping("/list")
    public TableDataInfo list(Processflow processflow)
    {
        startPage();
        List<Processflow> list = processflowService.selectProcessflowList(processflow);
        return getDataTable(list);
    }

    /**
     * 导出index列表
     */
    @PreAuthorize("@ss.hasPermi('camunda:processflow:export')")
    @Log(title = "index", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Processflow processflow)
    {
        List<Processflow> list = processflowService.selectProcessflowList(processflow);
        ExcelUtil<Processflow> util = new ExcelUtil<Processflow>(Processflow.class);
        util.exportExcel(response, list, "index数据");
    }

    /**
     * 获取index详细信息
     */
    @PreAuthorize("@ss.hasPermi('camunda:processflow:query')")
    @GetMapping(value = "/{pfid}")
    public AjaxResult getInfo(@PathVariable("pfid") Long pfid)
    {
        return success(processflowService.selectProcessflowByPfid(pfid));
    }

    /**
     * 新增index
     */
    @PreAuthorize("@ss.hasPermi('camunda:processflow:add')")
    @Log(title = "index", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Processflow processflow)
    {
        return toAjax(processflowService.insertProcessflow(processflow));
    }

    /**
     * 修改index
     */
    @PreAuthorize("@ss.hasPermi('camunda:processflow:edit')")
    @Log(title = "index", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Processflow processflow)
    {
        return toAjax(processflowService.updateProcessflow(processflow));
    }

    /**
     * 删除index
     */
    @PreAuthorize("@ss.hasPermi('camunda:processflow:remove')")
    @Log(title = "index", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pfids}")
    public AjaxResult remove(@PathVariable Long[] pfids)
    {
        return toAjax(processflowService.deleteProcessflowByPfids(pfids));
    }
}
